package com.ruoyi.web.controller.pollutant;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pollutant.domain.OutletExhaust;
import com.ruoyi.pollutant.service.IOutletExhaustService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 废气排放Controller
 * 
 * @author yxf
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/pollutant/atmosphere")
public class OutletExhaustController extends BaseController
{
    @Autowired
    private IOutletExhaustService outletExhaustService;

    /**
     * 查询废气排放列表
     */
    @PreAuthorize("@ss.hasPermi('pollutant:atmosphere:list')")
    @GetMapping("/list")
    public TableDataInfo list(OutletExhaust outletExhaust)
    {
        startPage();
        List<OutletExhaust> list = outletExhaustService.selectOutletExhaustList(outletExhaust);
        return getDataTable(list);
    }

    /**
     * 导出废气排放列表
     */
    @PreAuthorize("@ss.hasPermi('pollutant:atmosphere:export')")
    @Log(title = "废气排放", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OutletExhaust outletExhaust)
    {
        List<OutletExhaust> list = outletExhaustService.selectOutletExhaustList(outletExhaust);
        ExcelUtil<OutletExhaust> util = new ExcelUtil<OutletExhaust>(OutletExhaust.class);
        return util.exportExcel(list, "废气排放数据");
    }

    /**
     * 获取废气排放详细信息
     */
    @PreAuthorize("@ss.hasPermi('pollutant:atmosphere:query')")
    @GetMapping(value = "/{exoId}")
    public AjaxResult getInfo(@PathVariable("exoId") Long exoId)
    {
        return AjaxResult.success(outletExhaustService.selectOutletExhaustById(exoId));
    }

    /**
     * 新增废气排放
     */
    @PreAuthorize("@ss.hasPermi('pollutant:atmosphere:add')")
    @Log(title = "废气排放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OutletExhaust outletExhaust)
    {
        return toAjax(outletExhaustService.insertOutletExhaust(outletExhaust));
    }

    /**
     * 修改废气排放
     */
    @PreAuthorize("@ss.hasPermi('pollutant:atmosphere:edit')")
    @Log(title = "废气排放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OutletExhaust outletExhaust)
    {
        return toAjax(outletExhaustService.updateOutletExhaust(outletExhaust));
    }

    /**
     * 删除废气排放
     */
    @PreAuthorize("@ss.hasPermi('pollutant:atmosphere:remove')")
    @Log(title = "废气排放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{exoIds}")
    public AjaxResult remove(@PathVariable Long[] exoIds)
    {
        return toAjax(outletExhaustService.deleteOutletExhaustByIds(exoIds));
    }
}
